import React from 'react';
import ReactDOM from 'react-dom';

import Login from './components';
import store from './stores';

import { ecComFiles, comMobxFiles, portalPublicFiles } from '../portal4theme/constants/files';
import { loadModule } from '../portal4theme/util/loadjsUtil';

window.doLicenseSubmit = () => {
  loadModule({
    module: 'portalLogin',
    files: [...ecComFiles, ...comMobxFiles, ...portalPublicFiles],
    async: false,
    success: () => {
      const div = document.createElement('div');
      document.body.appendChild(div);
      const WeaLicenseSubmit = window.weaPortalPublic.WeaLicenseSubmit;
      ReactDOM.render(<WeaLicenseSubmit ecId={`${(this && this.props && this.props.ecId) || ''}_WeaLicenseSubmit@pm2vzo`} visible={true} from="login" />, div);
    },
  });
};

module.exports = { store, Login };
